<template>
  <div class="top-card-container">
    <div class="data-grid">
      <div class="data-item">
        <img
          class="item-icon"
          src="@/assets/images/bsc-ship-icon.png"
          alt="ship icon"
        />
        <div class="item-icon-xf">
          <div>
            <img
              class="xfimg xf1"
              src="@/assets/images/bsc-top-hz2.png"
              alt="hz2 icon"
              :style="{ transform: `translate3d(0px, 0px, 0px) scaleX(1) scaleY(1.1) rotateX(-53deg) rotateY(-20deg) rotateZ(${rotation}deg) skewX(0deg) skewY(0deg)` }"
            />
          </div>
          <div>
            <img
              class="xfimg"
              src="@/assets/images/bas-top-hz.png"
              alt="hz icon"
              :style="{ transform: `translate3d(0px, 0px, 0px) scaleX(1) scaleY(1.1) rotateX(-53deg) rotateY(-20deg) rotateZ(${rotation}deg) skewX(0deg) skewY(0deg)` }"
            />
          </div>
        </div>
      </div>
      <div
        v-for="(item, index) in data"
        :key="index"
        class="data-item"
        :style="{ borderColor: item.color }"
      >
        <div class="data-name" :style="{ color: item.color }">
          {{ item.name }}
        </div>
        <div class="data-value">
          <span
            class="value-number"
            :style="{ textShadow: `${item.color1} 0px 0px 10px` }"
          >{{ item.value }}</span>
          <span
            class="value-unit"
            :style="{ color: item.unitcolor || 'rgba(255, 235, 183, 0.5)' }"
          >{{ item.unit }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "BscTopCard",
  props: {
    data: {
      type: Array,
      required: true,
      default: () => [],
    },
  },
  data() {
    return {
      rotation: 0,
    };
  },
  mounted() {
    this.startRotation();
  },
  methods: {
    startRotation() {
      setInterval(() => {
        this.rotation += 3;
      }, 30); // 每30ms增加3度，旋转速度更快
    },
  },
};
</script>

<style scoped lang="scss">
.top-card-container {
  z-index: 3000;
  position: absolute;
  left: 50%;
  transform: translate(-50%, 0%);
  width: 70%;
  top: 18px;
  .data-grid {
    display: flex;
    width: 100%;
    .data-item {
      width: 18%;
      position: relative;
      .item-icon-xf {
        .xf1 {
          width: 65px;
          height: 65px;
        }
        .xfimg {
          display: block;
          position: absolute;
          left:18%;
          top: -3px;
          width: 75px;
          height: 75px;
          pointer-events: none;
          transition: transform 0.03s linear;
          contain: layout;
        }
      }
      .item-icon {
        width: 40px;
        height: 40px;
        display: block;
        margin: 10px auto 10px auto;
        object-fit: contain;
      }
      .data-name {
        font-size: 16px;
        font-family: SourceHanSansCN-Normal;
        letter-spacing: 2px;
        display: inline-block;
      }
      .data-value {
        display: flex;
        height: 50px;
        line-height: 50px;
        .value-number {
          padding: 0px;
          display: flex;
          font-size: 20px;
          font-family: 庞门正道标题体-免费商用;
          flex: 0 1 0%;
          margin: 0px;
          pointer-events: none;
          margin: 0px 1px;
          transform: translate3d(0px, 0px, 0px);
          font-size: inherit;
          width: auto;
          flex: 0 1 0%;
          text-align: center;
          color: #fff;
          // text-shadow: rgb(0, 187, 255) 0px 0px 10px;
        }
        .value-unit {
          font-size: 14px;
          font-family: SourceHanSansCN-Medium;
          transform: translate3d(8px, 0px, 0px);
          display: inline-block;
        }
      }
    }
  }
}
</style>
